<?php
$time = $_REQUEST['time'] ?: '本周';
$result = ['status' => 1, 'message' => []];
if($time == '本周'){
    $result['message'] = [
        'shangjidata' => [10,20,30,10,15,10,5],
        'jiechudata' => [30,25,45,35,15,20,30],
        'yansundata' => [40,50,60,35,25,40,50],
        'baofeidata' => [50,80,60,75,45,40,50]
    ];
}
elseif ($time == '本月'){
    $days_in_month = date('t');
    for ($i = 1; $i <= $days_in_month; $i++) {
        $result['message']['shangjidata'][] = rand(1,200);
        $result['message']['jiechudata'][] = rand(201,400);
        $result['message']['yansundata'][] = rand(401,600);
        $result['message']['baofeidata'][] = rand(601,800);
    }
}
elseif ($time == '本季度'){
    // 获取当前月份
    $current_month = date('n');
    // 计算当前月份所在的季度
    $current_quarter = ceil($current_month / 3);
    // 获取当前季度的第一个月份和最后一个月份
    $start_month = ($current_quarter - 1) * 3 + 1;
    $end_month = $current_quarter * 3;
    // 计算当前季度的总天数
    $total_days_in_quarter = 0;
    for ($month = $start_month; $month <= $end_month; $month++) {
        $total_days_in_quarter += cal_days_in_month(CAL_GREGORIAN, $month, date('Y'));
    }
    for ($i = 1; $i <= $total_days_in_quarter; $i++) {
        $result['message']['shangjidata'][] = rand(1,400);
        $result['message']['jiechudata'][] = rand(201,800);
        $result['message']['yansundata'][] = rand(401,1200);
        $result['message']['baofeidata'][] = rand(601,1600);
    }
}
elseif ($time == '本年度'){
    $result['message'] = [
        'shangjidata' => [10,25,30,41,30,60,50,80,92,100,110,120],
        'jiechudata' => [20,30,20,48,50,65,72,89,95,120,130,115],
        'yansundata' => [40,20,31,45,55,60,70,86,97,104,123,120],
        'baofeidata' => [10,20,30,40,50,61,75,81,90,100,110,125],
        'baofeidata' => [50,22,35,43,50,66,79,86,99,102,111,123]
    ];
}
die(json_encode($result,true));